﻿using Architecture.Api.Application.Commands.ImmuneInFormationCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using AutoMapper;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.ImmuneInFormationHandler
{
    public class ImmuneInFormationUpdateCommandHandler : IRequestHandler<ImmuneInFormationUpdateCommand, int>
    {
        private readonly ICultureService _cultureService;
        private readonly IMapper _mapper;

        public ImmuneInFormationUpdateCommandHandler(ICultureService cultureService,
                                                     IMapper mapper)
        {
            _cultureService = cultureService;
            _mapper = mapper;
        }

        public async Task<int> Handle(ImmuneInFormationUpdateCommand request, CancellationToken cancellationToken)
        {
            ImmuneInFormation immuneCommand = _mapper.Map<ImmuneInFormation>(request);
            return await _cultureService.UpdateImmuneInFormation(immuneCommand);
        }
    }
}
